<template>
	<view>
		<view class="textbox">
			<textarea name="" maxlength="-1" v-model="remarks" placeholder="请填写作废备注" id="" class="textcontent"></textarea>
		</view>
		<view class="btn" @click="$noMultipleClicks(toVoid)">确定</view>
	</view>
</template>

<script>
	import { netVoidInvoice, netVoidContract } from '@/api/api.js'
	
	export default{
		data() {
			return{
				noClick:true,    //防止  重复点击
				remarks:'',  //备注
				type:1,   //1合同  2发货单
				id:'', 
			}
		},
		onLoad(options) {
			this.id = options.id
			this.type = options.type
		},
		methods:{
			toVoid() {
				if(!this.remarks){
					uni.showToast({
						title:'请填写作废备注',
						icon:'none'
					})
					return
				}
				let params = {
					remarks:this.remarks
				}
				if(this.type == 1) {
					//合同
					params.contract_id = this.id
					netVoidContract(params).then(res=>{
						uni.showToast({
							title:res.msg,
							icon:'none'
						})
						setTimeout(()=>{
							uni.navigateBack({
								delta:2
							})
						},2000)
					})
				}else if(this.type == 2){
					//发货单
					params.delivery_id = this.id
					netVoidInvoice(params).then(res=>{
						uni.showToast({
							title:res.msg,
							icon:'none'
						})
						setTimeout(()=>{
							uni.navigateBack({
								delta:2
							})
						},2000)
					})
				}
				
			}
		}
	}
</script>

<style lang="scss" scoped>
	.textbox{
		background:#fff;
		padding:20rpx 24rpx;
		// margin: 20rpx;
		.textcontent{
			width:94%;
			height:300rpx;
			border-radius: 8rpx;
			border:1rpx solid #CCCCCC;
			padding:20rpx;
			margin: 0 auto;
		}
	}
	.btn{
		width:680rpx;
		height:80rpx;
		border-radius: 40rpx;
		background:$uni-color-primary;
		margin:100rpx auto;
		font-size:24rpx;
		color:#fff;
		text-align: center;
		line-height: 80rpx;
	}
</style>